<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <img src="./images/1.webp" alt="">
    <script>
        // 声明一个数组
        const arr = ['./images/1.webp', './images/2.webp', './images/3.webp', './images/4.webp', './images/5.webp', './images/6.webp']
        // 获取元素DOM对象
        const img = document.querySelector('img')
        // 获取随机数
        const i = Math.floor(Math.random() * arr.length)
        // 修改元素属性值
        img.src = arr[i]
    </script>
</body>

</html>